//
//  TabbarViewController.m
//  MilitaryDemo
//
//  Created by qianfeng01 on 15-7-4.
//  Copyright (c) 2015年 qianfeng01. All rights reserved.
//

#import "TabbarViewController.h"
#import "BaseViewController.h"
#import "WMPageController.h"
@interface TabbarViewController ()

@end

@implementation TabbarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatViewControllers];
}
-(void)creatViewControllers
{
    NSArray *titlesArr=@[@"资讯",@"图库",@"武器库",@"设置"];
    NSArray *imagesArr=@[@"main_home_normal",@"main_pic_normal",@"tujiejunshi",@"set_icon_night"];
   // NSArray *selectImagesArr= @[@"main_home_press",@"main_pic_press",@"main_user_press"];
    NSArray *MainCategoryArr=@[@"NewsViewController",@"PictureViewController",@"WeaponViewController",@"MyViewController"];
    NSArray *categoryTitlesArr=@[@"头条",@"热点",@"军事",@"历史",@"环球"];
    NSArray *CategoryArr=@[@"RecommedViewController",@"HotViewController",@"MilitaryViewController",@"HistoryViewController",@"EarthViewController"];
    NSMutableArray *vcArr=[[NSMutableArray alloc]init];
      NSMutableArray *allArr=[[NSMutableArray alloc]init];
    for (int i = 0;i< CategoryArr.count; i++) {
        Class cls = NSClassFromString(CategoryArr[i]);
        UIViewController *vc = [[cls alloc]init];
        [vcArr addObject:vc];
    }
    WMPageController *pvc = [[WMPageController alloc]initWithViewControllers:vcArr andTheirTitles:categoryTitlesArr];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:pvc];
    pvc.title=titlesArr[0];
    nav.tabBarItem.image=[UIImage imageNamed:imagesArr[0]];
    //nav.tabBarItem.selectedImage=[UIImage imageNamed:selectImagesArr[0]];
    [nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"header_bg.png"] forBarMetrics:UIBarMetricsDefault];
    [allArr addObject:nav];

    for (NSInteger i=1; i<MainCategoryArr.count; i++) {
        Class cls=NSClassFromString(MainCategoryArr[i]);
        BaseViewController *controller=[[cls alloc]init];
        UINavigationController *niv=[[UINavigationController alloc]initWithRootViewController:controller];
        controller.title=titlesArr[i];
        niv.tabBarItem.image=[UIImage imageNamed:imagesArr[i]];
       // niv.tabBarItem.selectedImage=[UIImage imageNamed:selectImagesArr[i]];
        [niv.navigationBar setBackgroundImage:[UIImage imageNamed:@"header_bg.png"] forBarMetrics:UIBarMetricsDefault];
        [allArr addObject:niv];
    }
    //[self.tabBar setBackgroundImage:[UIImage imageNamed:@"tab_bg.png"]];
    

    self.viewControllers=allArr;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
